package com.song.demo14springbootmybatisplus.config;

import com.baomidou.mybatisplus.extension.injector.methods.LogicDeleteByIdWithFill;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;


/**
 * 配置类  mybatis-plus
 */
@MapperScan("com.song.demo14springbootmybatisplus.mapper")
@EnableTransactionManagement  //开启事务管理
@Configuration  //配置类
public class MyBatisPlusConfig {



    //注册乐观锁插件
    @Bean
    public OptimisticLockerInterceptor OptimisticLockerInterceptor(){
            return new OptimisticLockerInterceptor();
    }

    //注册分页插件
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        return new PaginationInterceptor();
    }

    //注册逻辑删除
    @Bean
    public LogicDeleteByIdWithFill sqlInjector(){
        return new LogicDeleteByIdWithFill();
    }

}
